package com.hinnotek.amoeba.viewmodels

import androidx.lifecycle.viewModelScope
import com.lee.common.bean.LoginBean
import com.hinnotek.amoeba.repo.LoginRepo
import com.lee.common.base.BaseViewModel
import com.lee.common.network.net.StateLiveData
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.launch
import javax.inject.Inject

@HiltViewModel
class LoginViewModel @Inject constructor(private val repository: LoginRepo) :
    BaseViewModel() {

    private val loginData = StateLiveData<LoginBean>()

    fun userLoginNet(userName: String, password: String): StateLiveData<LoginBean> {
        viewModelScope.launch {
            repository.toLogin(userName, password, loginData)
        }
        return loginData
    }

}